{#
 # ---------------------------------------------------------------------
 #
 # GLPI - Gestionnaire Libre de Parc Informatique
 #
 # http://glpi-project.org
 #
 # @copyright 2015-2025 Teclib' and contributors.
 # @licence   https://www.gnu.org/licenses/gpl-3.0.html
 #
 # ---------------------------------------------------------------------
 #
 # LICENSE
 #
 # This file is part of GLPI.
 #
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 # the Free Software Foundation, either version 3 of the License, or
 # (at your option) any later version.
 #
 # This program is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 #
 # ---------------------------------------------------------------------
 #}

{% extends "generic_show_form.html.twig" %}
{% import 'components/form/fields_macros.html.twig' as fields %}

{% block form_fields %}
    {{ fields.dropdownItemTypes('itemtype', item.fields['itemtype'], __('Item type'), {
        types: config('databaseinstance_types'),
        rand: rand,
    }) }}
    {% if item.fields['itemtype'] %}
        {% do call('Ajax::updateItemOnSelectEvent', [
            'dropdown_itemtype' ~ rand,
            'items_id' ~ rand,
            config('root_doc') ~ '/ajax/dropdownAllItems.php',
            {
                itemtype: '__VALUE__',
                dom_rand: rand,
                dom_name: 'items_id',
                action: 'get_items_from_itemtype'
            }
        ]) %}
        {{ fields.dropdownField(item.fields['itemtype'], 'items_id', item.fields['items_id'], _x('Item', 'Items', 1)) }}
    {% else %}
        {% do call('Ajax::updateItemOnSelectEvent', [
            'dropdown_itemtype' ~ rand,
            'results_itemtype' ~ rand,
            config('root_doc') ~ '/ajax/dropdownAllItems.php',
            {
                idtable: '__VALUE__',
                rand: rand,
                name: 'items_id',
                width: 'unset'
            }
        ]) %}
        {% set result_itemtype_field %}
            <span id="results_itemtype{{ rand }}"></span>
        {% endset %}
        {{ fields.htmlField('', result_itemtype_field, _x('Item', 'Items', 1)) }}
    {% endif %}
    {{ parent() }}
{% endblock %}

{% block more_fields %}
    {{ fields.dropdownField(
        'DatabaseInstanceCategory',
        'databaseinstancecategories_id',
        item.fields['databaseinstancecategories_id'],
        'DatabaseInstanceCategory'|itemtype_name
    ) }}
    {{ fields.dropdownYesNo('is_onbackup', item.fields['is_onbackup'], __('Has backup')) }}
    {{ fields.datetimeField('date_lastbackup', item.fields['date_lastbackup'], __('Last backup date'), {
        maybeempty: true,
    }) }}
    {{ fields.textField('port', item.fields['port'], _n('Port', 'Ports', 1)) }}
    {{ fields.textField('path', item.fields['path'], __('Path')) }}
{% endblock %}
